#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;

struct node
{
	int a, b, g, k;
}a[N];

int n, x, y;

int main()
{
	cin >> n;
	for(int i = 1;i <= n;i ++) cin >> a[i].a >> a[i].b >> a[i].g >> a[i].k;
	cin >> x >> y;
	bool flag = true;
	for(int i = n;i >= 1;i --)
	{
		int x1 = a[i].a, y1 = a[i].b, x2 = x1 + a[i].g - 1, y2 = y1 + a[i].k - 1;
		if(x <= x2 && x >= x1 && y <= y2 && y >= y1)
		{
			cout << i << endl;
			flag = false;
			break;
		}
	}
	if(flag) cout << -1 << endl;
	return 0;
}